package com.example.abe.diandi.main;

import com.tencent.bugly.crashreport.CrashReport;
import com.yanzhenjie.nohttp.Logger;
import com.yanzhenjie.nohttp.NoHttp;
import com.yanzhenjie.nohttp.OkHttpNetworkExecutor;
import com.yanzhenjie.nohttp.cache.DBCacheStore;
import com.yanzhenjie.nohttp.cookie.DBCookieStore;

import example.abe.com.framework.main.BaseApplication;

/**
 * Created by abe on 16/10/16.
 */
public class MyApplication extends BaseApplication {

    private static MyApplication instance;

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;

        init();
    }

    private void init() {
        // NoHttp配置
        NoHttp.initialize(this, new NoHttp.Config()
                .setConnectTimeout(30 * 1000)
                .setReadTimeout(30 * 1000)
                .setCacheStore(new DBCacheStore(this).setEnable(true))
                .setCookieStore(new DBCookieStore(this).setEnable(true))
                .setNetworkExecutor(new OkHttpNetworkExecutor()));
        //开启NoHttp调试模式。
        Logger.setDebug(true);
        Logger.setTag("NoHttp-Diandi");

        //Bugly配置，配置内容在AndroidManifest.xml中
        CrashReport.initCrashReport(getApplicationContext());
    }

    public static MyApplication getInstance() {
        return instance;
    }
}
